package com.peter.springcloud.eurekaconsumer.ribbon;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@EnableDiscoveryClient
@SpringBootApplication
public class Application {
    // MEMO 与项目 eureka-consumer 不同之处，这里增加了一个注解 LoadBalanced 。使得 restTemplate 具备负载均衡能力。
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    public static void main( String[] args ) {
        new SpringApplicationBuilder(Application.class).web(true).run(args);
    }
}
